package edu.chen.controller;


import edu.chen.entity.Book;
import edu.chen.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/book")
public class BookController {

    @Autowired
    private BookService bookService;

    /**
     * 查询所有书本信息
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    private ModelAndView list(ModelAndView modelAndView){
        List<Book> books = bookService.list();
        modelAndView.getModel().put("books",books);
        modelAndView.setViewName("list");
        return modelAndView;
    }

}
